package com.xcjh.opencv.emuns;

import java.util.Objects;

/**
 * 匹配的图片
 */
public enum CommdType {

    /**
     * debug
     */
    鼠标移动("MoveTo","鼠标移动"),
    /**
     * 禁用
     */
    延迟("delay","延迟"),
    /**
     * 左键按下
     */
    左键按下("leftDown","左键按下"),
    /**
     * 右键按下
     */
    右键按下("rightDown","右键按下"),
    左键抬起("leftUp","左键抬起"),
    右键抬起("rightUp","右键抬起"),
    左键单击("leftClick","左键单击"),
    右键单击("rightClick","右键单击"),
    中键单击("middleClick","中键单击"),
    左键双击("leftDoubleClick","左键双击"),
    鼠标中键滚动("mouseWheel","鼠标中键滚动"),
    键盘按下("keyDown","键盘按下"),
    键盘按弹起("keyUp","键盘弹起"),

    ;

    private String code;
    private String message;

    private CommdType(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static CommdType findByKey(String key) {

        CommdType result = null;

        for (CommdType s : values()) {
            if (s.getCode().equalsIgnoreCase(key)) {
                result = s;
                break;
            }
        }

        return result;
    }

    public static CommdType findByMsg(String msg) {

        CommdType result = null;

        for (CommdType s : values()) {
            if (s.getMessage().equalsIgnoreCase(msg)) {
                result = s;
                break;
            }
        }

        return result;
    }
}